//
// Created by ca on 2022/8/18.
//

#ifndef LIDAR_SERVICE_DATA_RECORD_H
#define LIDAR_SERVICE_DATA_RECORD_H

#include <memory>
#include <list>
#include <set>
#include <unordered_set>
#include "ktime.h"
#include "crecord.h"
#include <memory>
#include <thread>
#include <raw_data.h>
#include <functional>
#include "data_structure.h"
#include "dat_parser.h"
/**
 * the class which makes connection with class spRecord and other classes needing the recording function
 */
class DataRecord
{

public:
    explicit DataRecord();

    ~DataRecord();

    /**
     * @brief the record function is record data
     * @param filePath 文件路径
     * @param eventCode 事件ID
     */
    void record(const std::string &topicName, const double &timeStamp, const std::string &dataStr);
    void recordCalibFile();
    void GenerateMessage(std::string file_name, std::string &message,std::string calibData);
    /**
     * @brief initializeRecord function is initialized
     * @param filePath 文件路径
     * @param eventCode 事件ID
     */
    std::string initializeRecord(const std::string &filePath, const std::string &eventCode, const std::string &fileType, const uint64_t &recordTime,const double &triggerTime,const double &triggerStartTime);
    std::string initializeRecord(const std::string &tuominFileWithPath);

    /**
     * @brief getFileName 获取事件信息
     * @param filePath 文件路径
     * @param eventCode 事件ID
     */
    static std::string getFileName(const std::string &filePath, const std::string &eventCode, const std::string &fileType, const uint64_t &recordTime);

    /**
     * @brief getFileNameType 获取事件文件名称类型字段
     * @param topic 文件路径
     */
    static std::string getFileNameType(const std::string &topic);
    static std::string getEvtFromDat(const string &datName);
    static bool convertDesensFiletype(const std::string &fileName, std::string &desensFileName);


    std::string m_fileName;

private:
    std::shared_ptr<CRecord> spRecord = nullptr;
    static int32_t m_eventPrefixLenPos;
    double m_TriggerUTCtime=0.0;
    double m_TriggerStartTime=0.0;
    double m_FirstFrameUTCTime=0.0;
    bool m_isfirstFrame=true;
};

#endif // LIDAR_SERVICE_RECORD_INTERACTION_H
